package umlproject;

import java.util.HashMap;

public class Filmdatabase extends HashMap<Integer, Film>{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	public int price(int imdb_id) throws NullPointerException{
		 Film f=this.get(imdb_id);
		     if(f==null){
		    	 throw new NullPointerException();
		     } 
			 return f.price;
		
	}
	public String name(int imdb_id) throws NullPointerException{
		 Film f=this.get(imdb_id);
		     if(f==null){
		    	 throw new NullPointerException();
		     } 
			 return f.title;
	}
	public void put(int imdb_id, String title, int price, int TempLivraison, String siteAchat){
		Film f=new Film();
		f.id=imdb_id;
		f.title=title;
		f.price=price;
                f.TempsLivraison = TempLivraison;
                f.siteAchat = siteAchat;
		this.put(imdb_id,f);
		
	}
        
        public int surchIndex(String NomFilm){
            int index = -1;
            for(int k = 0 ; k < this.size() ;k++){
                if(this.get(k).title.equals(NomFilm)){
                    index = k;
                }
            }
            return index;
        }
	
}
